{{include './header.html'}}
  <div class="container">
    <form action="" class="form-horizontal register">
      <div class="form-group">
        <label for="" class="col-sm-2 control-label">用户名：</label>
        <div class="col-sm-9">
          <input type="text" name="username" id="" class="form-control">
        </div>
      </div>
      <div class="form-group">
        <label for="" class="col-sm-2 control-label">密码：</label>
        <div class="col-sm-9">
          <input type="text" name="psw" id="" class="form-control">
        </div>
      </div>
      <div class="form-group">
        <label for="" class="col-sm-2 control-label">电话号码：</label>
        <div class="col-sm-9">
          <input type="text" name="phone" id="" class="form-control">
        </div>
      </div>
      <div class="form-group" style="text-align: center;">
        <button class="btn btn-success" style="width: 100px;">注册</button>
        <button type="button" class="btn btn-primary back" style="width: 100px; margin-left: 15px;">返回</button>
      </div>
    
    </form>
  </div>
  <script>
    $('.back').click(function(){
      history.go(-1)
    })

    $('.register').submit(function(e){
       e.preventDefault()
       var username= $('.register').find('input').eq(0).val()
       $.post('/register',$(this).serialize(),data=>{
         $('#showinfo').modal('show').find('.modal-body').text(data.msg)
         $('#showinfo').on('hide.bs.modal', function () {
            if(data.code==1){
              var now = new Date()
              now.setMonth(now.getMonth()+1)
              $.cookie('username',username,{expires:now})
              location.href='/'
            }else{
              $('.register').find('input').val('')
            }
         })
       })
      
    })
  </script>
</body>
</html>